In the field of data synchronization technologies, a Raft consistency algorithm is widely applied to a distributed storage system.
Currently, data in a distributed storage system based on the Raft consistency algorithm is divided into multiple data block groups. Each data block group includes multiple same data blocks separately stored in different storage devices. During implementation of the Raft consistency algorithm, data is synchronized by using a data block group as a unit. Specifically, for a data block group, storage devices in which data blocks of the data block group are located first elect a primary device for the data block group. Correspondingly, another device is a secondary device for the data block group. The primary device is responsible for processing interaction with a client. When receiving a read/write instruction sent by the client, the primary device records the read/write instruction as a log, and sends a data synchronization instruction that includes the log to each secondary device according to a fixed heartbeat time. Each secondary device synchronizes data according to the data synchronization instruction. If there is no to-be-sent log when the heartbeat time elapses, the primary device needs to send a heartbeat signal that includes no data synchronization instruction to each secondary device, so as to determine that a connection is normal.
In a process of implementing the present application, the inventor finds that the prior art has at least the following problem:
In an existing Raft consistency algorithm, heartbeat times of various data block groups are a fixed value, but read/write frequencies of the data block groups are not even. The fixed value is generally set to be relatively small, so as to ensure that all data blocks in a data block group of a relatively high read/write frequency can be synchronized in a timely manner. Consequently, a signal also needs to be frequently received and sent between all storage devices in which a data block group of a relatively low read/write frequency is located, thereby causing relatively large system overheads, and affecting read/write performance of a storage system.